package com.wf.smartcomm.server.bean;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.google.gson.annotations.Expose;
import com.wf.smartcomm.server.util.StringUtil;

/** 
 * @author 38884306@qq.com  
 * @version 
 * 
 */
@Entity
@Table(name = "t_unitMachine")
public class UnitMachine {
	@Expose
	@Id
	@Column(length = 32)
	private String objectId;
	
	@Expose
	@Column(length = 32)
	private String ipAddress;
	
	@Expose
	@Column(length = 10)
	private String region;//区
	
	@Expose
	@Column(length = 32)
	private String placeDes;
	
	@Expose
	@Column(length = 32)
	private String macAddress;
	
	@Expose
	@Column(length = 32)
	private String hardVersion;
	
	@Expose
	@Column(length = 32)
	private String hardwareId;
	
	@Expose
	@Column(length = 16)
	private String pushId;
	
	@Expose
	@Column(length = 32)
	private String softVersion;
	
	@Expose
	@Column(length = 10)
	private String groupNo;
	
	@Column(length = 20)
	private String lastRebootTime;
	
	@Expose
	@Column(length = 20)
	private String lastReportTime;
	
	@Expose
	@Column(length = 20)
	private String timeSpan;
	
	@Expose
	@Column
	private Integer screenSize;
	
	@ManyToMany
	@JoinTable(name="t_machine_relation_house",joinColumns={@JoinColumn(name="mid")},inverseJoinColumns={@JoinColumn(name="hid")})
	private Set<House> houses;
	
	@Expose
	@OneToOne(fetch=FetchType.EAGER)
	@JoinColumn(name = "uid")
	private User user;
	
	
	public Integer getScreenSize() {
		return screenSize;
	}

	public void setScreenSize(Integer screenSize) {
		this.screenSize = screenSize;
	}

	@ManyToOne
	@JoinColumn(name = "vid")
	private Village village;
	
	@Expose
	@Column(length = 10)
	private String building;
	
	@Expose
	@Column(length = 10)
	private String entrance;
	
	@Expose
	@Column(length = 10)
	private String number;
	
	@Expose
	@Column(length = 1)
	private String online;
	
	@Column(length = 20)
	private String createdAt;
	
	@Column(length = 20)
	private String updateAt;
	
	@Expose
	@Column(length = 64)
	private String voipNumber;
	
	@Expose
	@Column(length = 64)
	private String voipLandingAccount;

	@Expose
	@Column(length = 64)
	private String voipLandingPwd;

	@Expose
	@Column(length = 64)
	private String subLandingAccountSid;

	@Expose
	@Column(length = 64)
	private String subLandingToken;

	
	@Expose
	@Column(length = 1)
	private String type;
	
	public UnitMachine(String mid) {
		this.objectId = mid;
	}
	
	public UnitMachine(){
		
	}

	public String getTimeSpan() {
		return timeSpan;
	}

	public void setTimeSpan(String timeSpan) {
		this.timeSpan = timeSpan;
	}

	public Village getVillage() {
		return village;
	}

	public void setVillage(Village village) {
		this.village = village;
	}

	public String getLastReportTime() {
		return lastReportTime;
	}

	public void setLastReportTime(String lastReportTime) {
		this.lastReportTime = lastReportTime;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getCreatedAt() {
		return createdAt;
	}

	public void setCreatedAt(String createdAt) {
		this.createdAt = createdAt;
	}

	public String getUpdateAt() {
		return updateAt;
	}

	public String getHardwareId() {
		return hardwareId;
	}

	public void setHardwareId(String hardwareId) {
		this.hardwareId = hardwareId;
	}

	public void setUpdateAt(String updateAt) {
		this.updateAt = updateAt;
	}

	public String getObjectId() {
		return objectId;
	}

	public void setObjectId(String objectId) {
		this.objectId = objectId;
	}

	public String getIpAddress() {
		return ipAddress;
	}

	public void setIpAddress(String ipAddress) {
		this.ipAddress = ipAddress;
	}

	/*public Set<House> getHouses() {
		return houses;
	}

	public void setHouses(Set<House> houses) {
		this.houses = houses;
	}*/

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getBuilding() {
		return building;
	}

	public void setBuilding(String building) {
		this.building = building;
	}

	public String getEntrance() {
		return entrance;
	}

	public void setEntrance(String entrance) {
		this.entrance = entrance;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public String getOnline() {
		return online;
	}

	public void setOnline(String online) {
		this.online = online;
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	public String getPlaceDes() {
		return placeDes;
	}

	public void setPlaceDes(String placeDes) {
		this.placeDes = placeDes;
	}

	public String getMacAddress() {
		return macAddress;
	}

	public void setMacAddress(String macAddress) {
		this.macAddress = macAddress;
	}

	public String getHardVersion() {
		return hardVersion;
	}

	public void setHardVersion(String hardVersion) {
		this.hardVersion = hardVersion;
	}

	public String getSoftVersion() {
		return softVersion;
	}

	public void setSoftVersion(String softVersion) {
		this.softVersion = softVersion;
	}

	public String getGroupNo() {
		return groupNo;
	}

	public void setGroupNo(String groupNo) {
		this.groupNo = groupNo;
	}

	public String getLastRebootTime() {
		return lastRebootTime;
	}

	public void setLastRebootTime(String lastRebootTime) {
		this.lastRebootTime = lastRebootTime;
	}

	/*public Set<User> getUsers() {
		return users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}*/
	
	public void update(UnitMachine um){
		if (!StringUtil.isEmpty(um.lastRebootTime)) {
			lastRebootTime = um.lastRebootTime;
		}
		
		if (!StringUtil.isEmpty(um.softVersion)) {
			softVersion = um.softVersion;
		}
		
		if (!StringUtil.isEmpty(um.hardVersion)) {
			hardVersion = um.hardVersion;
		}
		
		if (!StringUtil.isEmpty(um.ipAddress)) {
			ipAddress = um.ipAddress;
		}
		
		if (!StringUtil.isEmpty(um.macAddress)) {
			macAddress = um.macAddress;
		}
		
		if (!StringUtil.isEmpty(um.timeSpan)) {
			timeSpan = um.timeSpan;
		}
	}
	

	public String getVoipNumber() {
		return voipNumber;
	}

	public void setVoipNumber(String voipNumber) {
		this.voipNumber = voipNumber;
	}

	public String getPushId() {
		return pushId;
	}

	public void setPushId(String pushId) {
		this.pushId = pushId;
	}

	public Set<House> getHouses() {
		return houses;
	}

	public void setHouses(Set<House> houses) {
		this.houses = houses;
	}

	public String getVoipLandingAccount() {
		return voipLandingAccount;
	}

	public void setVoipLandingAccount(String voipLandingAccount) {
		this.voipLandingAccount = voipLandingAccount;
	}

	public String getVoipLandingPwd() {
		return voipLandingPwd;
	}

	public void setVoipLandingPwd(String voipLandingPwd) {
		this.voipLandingPwd = voipLandingPwd;
	}

	public String getSubLandingAccountSid() {
		return subLandingAccountSid;
	}

	public void setSubLandingAccountSid(String subLandingAccountSid) {
		this.subLandingAccountSid = subLandingAccountSid;
	}

	public String getSubLandingToken() {
		return subLandingToken;
	}

	public void setSubLandingToken(String subLandingToken) {
		this.subLandingToken = subLandingToken;
	}
	
}
